package com.frx.leetoffer.subset;

import java.util.Arrays;

/**
 * @author ：frx
 * @date ：Created in 2019/10/31 19:23
 * @description：ToDO
 * @modified By：
 * @version: ToDO
 */
public class SubSet {

    public static void main(String[] args){
        int[] arr = {1,2,3};
        int[] x = new int[arr.length];
        backstrace(arr,0,x);
    }

    public static void backstrace(int[] arr,int i,int[] x){
        System.out.println(Arrays.toString(x));
        if (i==arr.length){
            for (int j=0;j<arr.length;j++){
                if (x[j] == 1){
                    System.out.print(arr[j] + " ");
                }
            }
            System.out.println();
        } else {
            x[i] = 1;
            backstrace(arr,i+1,x);
            x[i] = 0;
            backstrace(arr,i+1,x);
        }
    }
}
